package com.xyb.controller;

import com.xyb.service.WebUserService;
import com.xyb.vo.RegisterUserVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("user")
public class WebUserController {
    @Resource
    private WebUserService webUserService;

    /**
     * 查询手机号是否注册
     * @param vo
     * @return
     */
    @GetMapping("iphone-no")
    public boolean selectIphoneIsRegistered(@Validated(RegisterUserVo.checkIphoneNo.class) RegisterUserVo vo){
        return webUserService.selectIphoneIsRegistered(vo.getIphoneNo());
    }

    /**
     * 查询邮箱是否注册
     * @param vo
     * @return
     */
    @GetMapping("email")
    public boolean selectEmailIsRegistered(@Validated(RegisterUserVo.checkEmail.class) RegisterUserVo vo){
        return webUserService.selectEmailIsRegistered(vo.getEmail());
    }
}
